Bug 4742723

Bug Description:

This is a race bug.
This bug only affects Windows OS. Linux is not affected.
Expected message from test is:
===========Test failed======================
Two directories are expected to be created, but only one is created.
Missing a directory
============================================
More details about this bug are at JDK-4742723 JIRA page.

Interleaving Description:

The numbers in the following code snippets present the global execution sequence.

java.io.File:
	
t1      t2      public boolean mkdirs() {
1,7     4,10        if (exists()) {
        11              return false;
                    }
8                   if (mkdir()) {
9                       return true;
                    }
                    File canonFile = null;
                    try {
                        canonFile = getCanonicalFile();
                    } catch (IOException e) {
                        return false;
                    }
2       5           String parent = canonFile.getParent();
3       6           return (parent != null) && 
                        (new File(parent, fs.prefixLength(parent)).mkdirs() &&
                                canonFile.mkdir());
                }

Precondition:
t1 calls new File(projectBase+"\base\a").mkdirs();
t2 calls new File(projectBase+"\base\b").mkdirs();

a) t1 checks if projectBase\base\a exists at 1, here is false.
b) t1 gets parent path at 2, now parent is projectBase\base.
c) t1 tries to create parent directory first at 3
d) context switched. t2 checks projectBase\base\b at 4, here is false;
e) t1 gets parent path at 5, now parent is projectBase\base.
f) t1 tries to create parent directory first at 6
g) context switched, t1 checks if the parent directory projectBase\base exists at 7. Here is false.
h) t1 creates projectBase\base directory at 8.
i) t1 successfully created parent directory projectBase\base and return true at 9 to continue.
j) context switched, t2 checks if parent projectBase\base exists at 10.
k) parent directory has been created by t1 at step h), so t2 return false at 11.

Now t1 continues to create projectBase\base\a, but t2 aborts creating, so only directory projectBase\base\a is created.

How To Reproduce:

This bug is reproduced under JDK 1.6.0.
It affects since JDK 1.6.0, and has been fixed since JDK 1.6.0_02.
Execute the following scripts to run the test to reproduce the bug (assume the location of the jdk6 test project is jdk_test_home).

Linux:
${jdk_test_home}/scripts/4742723.sh [--javaloc path]
Windows:
%jdk_test_home%\scripts\4742723.bat [--javaloc path]

Option Function
--javaloc The location of JDK that is eligible to reproduce the bug, if your java environment is not eligible.
In this case, it's JDK 1.6.0. It should be the absolute path to the JDK's java starter and ended with "/".
For example: ~/jdk/home/jdk1.6.0/bin/